from typing import Union, Annotated

from fastapi import APIRouter, Query

from app.core.database import SessionDep
from sqlmodel import select

from app.models.system_admin import SystemAdmin

router = APIRouter(prefix="/items", tags=["items"])


@router.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}

@router.get("/lists")
def list_admin(
    session: SessionDep,
    offset: int = 0,
    limit: Annotated[int, Query(le=100)] = 100,
) -> list[SystemAdmin]:
    heroes = session.exec(select(SystemAdmin).offset(offset).limit(limit)).all()
    return heroes